# -*- coding: utf-8 -*-

import Map
import Item
import Tile
import Creature
import Pic

import pygame, sys



def saveMap(kartor):
    fil = open("kartor.txt", "w+")
    for karta in kartor:
        for row in karta.tiles:
            for tile in row:
                namn = tile.pic.name
                fil.write(namn + ";")
            fil.write("@")
        fil.write("%")
    fil.close()
def readMap():
    fil = open("kartor.txt", "r+")
    text = fil.read();
    kartor = text.split('%')
    kartor = kartor[:-1]
    kartor = list(map(lambda x: x.split('@'), kartor))
    for karta in kartor:
        karta = karta[:-1]
        karta = karta.split(';')
        for tile in karta:
            
        
    kartor = kartor[:-1]
    kartor = list(map(lambda x: x.split(';'), kartor))
    for karta in kartor:
        tiles = karta.split('@')
        tiles = tiles[:-1]
        for tile in tiles:
            names = tile.split(';')
            names = names[:-1]
            
